﻿using HZYProject.Core.Repositories;
using HZYProject.Data;
using HZYProject.Domain;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HZYProject.Web.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        private readonly IMemoryCache _memoryCache;
        public HomeController(IMemoryCache memoryCache)
        {
            _memoryCache = memoryCache;
        }
        [Route("")]
        public IActionResult Index()
        {
            return View();
        }

        [HttpGet("main")]
        public IActionResult Main()
        {
            DateTime time=DateTime.Now;
            if (!_memoryCache.TryGetValue("t", out time))
            {
                _memoryCache.Set("t", DateTime.Now);
            }
            ViewBag.Time = time;
            return View();
        }
    }
}
